package cn.kgc.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author: mosin
 * @version: v1.0  2022/5/6
 * springmvc异常处理
 */
@Controller
@RequestMapping("/exception")
public class ExceptionController {


    //@ExceptionHandler(ArithmeticException.class)
    //public  String  exeptionHandler1(Exception e){
    //    System.out.println("error msg:"+e.getMessage());
    //    return  "redirect:/static/error1.jsp";
    //}
    //
    //@ExceptionHandler(NullPointerException.class)
    //public  String  exeptionHandler2(Exception e){
    //    System.out.println("error msg:"+e.getMessage());
    //    return  "redirect:/static/error2.jsp";
    //}



    @RequestMapping("e1")
    public  String  test01(){
        int i = 1/0;
        return  "success";
    }

    @RequestMapping("e2")
    public  String  test02(){
        String str = null;
        boolean b = str.endsWith(".");
        return  "success";
    }


}
